<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('词库修改')" />
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body>
<div class="container-div">
    <div class="row">
        <b>
            <span style="color: red">{name}</span> 是机器人对你的称呼<br/>
            <span style="color: red">{me}</span> 是机器人对自己的称呼<br/>
            <span style="color: red">{segment}</span> 是分段发送消息
        </b>
        <div class="col-sm-12 search-collapse">
            <form id="thesaurus-form">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>问题：</label>
                            <input type="text" id="msgIssue" name="msgIssue" placeholder="问题">
                        </li>
                        <li>
                            <label>回答：</label>
                            <input type="text" id="msgReply" name="msgReply" placeholder="回答">
                        </li>
                        <li>
                            <label>群组： </label>
                            <input type="text" placeholder="QQ群"
                                   name="msgCreateGroup"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="searchPre()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="resetPre()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    var prefix = ctx + "bot/ai/thesaurus"

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "词库",
            queryParams: queryParams,
            sortOrder: "desc",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            columns: [
                {
                    field: 'state',
                    radio: true
                },
                {
                    field: 'msgIssue',
                    title: '问题'
                },
                {
                    field: 'msgIssueImage',
                    title: '图片MD5集合'
                },
                {
                    field: 'msgIssueFace',
                    title: '表情ID集合'
                },
                {
                    field: 'msgReply',
                    title: '文字回答'
                },
                {
                    field: 'msgReplyImage',
                    title: '图片Url地址集合'
                },{
                    field: 'msgReplyFace',
                    title: '表情ID集合'
                },{
                    field: 'msgCreateTime',
                    title: '创建日期'
                },{
                    field: 'msgCreateGroup',
                    title: '创建群组'
                },{
                    field: 'msgCreateMember',
                    title: '创建人员'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.msgId !== 0) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(' + row.msgId + ')"><i class="fa fa-edit"></i>修改</a> ');
                            actions.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)" onclick="$.operate.remove(' + row.msgId + ')"><i class="fa fa-trash"></i>删除</a>');
                            return actions.join('');
                        }
                    }
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        return $.table.queryParams(params);
    }

    function searchPre() {
        $.table.search('thesaurus-form', 'bootstrap-table');
    }

    function resetPre() {
        $("#thesaurus-form")[0].reset();
        $.table.search('thesaurus-form', 'bootstrap-table');
    }
</script>

</body>
</html>